﻿namespace Searches
{
    public class InsertionSort : ISortingAlgorythm
    {
        public void Sort(int[] array)
        {
            for (int i = 1; i < array.Length; i++)
            {
                int newElement = array[i];
                int location = i - 1;
                while (location >= 0 && array[location] > newElement)
                {
                    array[location + 1] = array[location];
                    location--;
                }
                array[location + 1] = newElement;
            }
        }
    }
}